function main(defaultParams) {
    debugger
    const self = this;
    let formPartEle = this.$$element("form_part_3jhm74");

    if (formPartEle) {
        formPartEle.$$getRenderElement().onSave().then((res) => {
            let unitId = res.result.documentNo;
            let fileId1 = self.$$("upload_9aurrp").cValue[0];
            let fileId2 = self.$$("upload_47i7m7").cValue[0];

            let toDocumentNoList = self.$$("text_input_b7ss15").cValue.split(",");
            let toUniqueId1 = "upload_9aurrp";
            let toUniqueId2 = "upload_47i7m7";
            let toPageId = self.$$("text_input_hf0llm").cValue;

            let saveFile1Params = {
                unitId: unitId,
                fileId: fileId1,
                toDocumentNoList: toDocumentNoList,
                toUniqueId: toUniqueId1,
                toPageId: toPageId
            };

            let saveFile2Params = {
                unitId: unitId,
                fileId: fileId2,
                toDocumentNoList: toDocumentNoList,
                toUniqueId: toUniqueId2,
                toPageId: toPageId
            };
            saveUnitMedia(saveFile1Params).then(r => {
                saveUnitMedia(saveFile2Params).then(r => {

                    // 发起流程申请
                    submitProcess(self, defaultParams, documentNo).then(res => {
                        console.log(res);
                    })
                })
            })


        });
    }
}

/**
 * 发起流程申请
 * @param self
 * @param defaultParams
 * @param documentNo
 * @returns {Promise<unknown>}
 */
function submitProcess(self, defaultParams, documentNo) {
    return new Promise((resolve, reject) => {
            console.log(defaultParams);
            const queryParams = [{
                "name": "pageId",
                "valueContent": "a7a88151-bd54-42c5-9520-249ebbbe5c45"
            }];
            const jsonParams = {
                "documentNo": documentNo
            };

            api.DATA_SOURCE_EXECUTE("a2b29830-9ef5-437a-8975-476783d4e73f", "api", queryParams, [], JSON.stringify(jsonParams)).then((res) => {
                console.log("响应", res);
                if (!res.hasError) {
                    resolve(res);
                } else {
                    self.$message.error(res.message);
                }
            }).catch(err => {
                self.$message.error(err.message);
                reject(err)
            });
        }
    );
}

function saveUnitMedia(params) {
    return new Promise((resolve, reject) => {
        api.DATA_SOURCE_EXECUTE("ds_api:62e8fd9a-7797-4626-ba17-9635683e7a74", "api", [], [], JSON.stringify(params))
            .then(res => {
                resolve(res); // 确保 Promise 有返回值
            }).catch(err => {
            reject(err); // 处理错误情况
        });
    });
}
